package com.yanqu.road.server.timer.monopolymarket;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.server.manger.monopolymarket.MonopolyMarketMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @Description
 * @Author cwq
 * @Data 2021/9/5 19:24
 */
public class MonopolyMarketTask extends GeneralTask {

    protected Logger logger = LogManager.getLogger(MonopolyMarketTask.class.getName());

    @Override
    public void doRun() {
        try {
            // 同步榷场玩家 和派遣门客的数据
            MonopolyMarketMgr.uploadUserInfo();
            MonopolyMarketMgr.uploadObjectInfo();
            // 同步榷场的分组  启动执行一次
            if(!MonopolyMarketMgr.isSyn){
                // 区服启动向区服拿分组配置
                YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(CrossProtocol.C_CROSS_MONOPOLY_MARKET_SYN_CROSS_GROUP);
                GamePlayerMgr.sendPacket(0, pbMsg);
            }
        }catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
}
